<?php
class JobAction extends Action{
	public function _initialize(){
	    R("Home.Public","top");
		R("Home.Public","bottom");	
	}
	public function index(){
	  import("ORG.Com.DiyCache");
	  $mycache = new DiyCache;
	  if(!$mycache->is_cached()){//处理自定义缓存
	     $job = M("job");
		 Vendor("LJW.Page");
		 $count = $job->count();
		 $pagesize = 8;
		 $mypage = new Page($count,$pagesize,3,U("Job/index"));
		 
		 $job_list = $job->limit($mypage->start.",".$mypage->pagesize)->order("sequence desc")->findAll();
		 
		 
		 $this->assign("job_list",$job_list);
		 
		 /*分页处理开始*/
		 $f_url=$mypage->url."/p/1";//首页
		 $e_url=$mypage->url."/p/".$mypage->pagenum;//尾页
             
		 $p_url=$mypage->url."/p/".(($mypage->absolutepage-1<=0)?1:($mypage->absolutepage-1));//上一页
		 $n_url=$mypage->url."/p/".(($mypage->absolutepage+1>$mypage->pagenum)?$mypage->pagenum:($mypage->absolutepage+1));//下一页
		 
		 $web_public_path = WEB_PUBLIC_PATH;
		 
		 
		 $div_str = <<<EOT
		 <ul><li><a href="{$f_url}"><img src="{$web_public_path}/images/home/prolist_22.gif" /></a></li><li><a href="{$p_url}"><img src="{$web_public_path}/images/home/prolist_24.gif" /></a></li>
EOT;
        for($i=1;$i<=$mypage->pagenum;$i++){
			    $u=$mypage->url."/p/$i";
			    $div_str.="<li><a href='$u'>$i</a></li>";
		}
		$div_str.=<<<EOT
		<li><a href="{$n_url}"><img src="{$web_public_path}/images/home/prolist_27.gif" /></a></li><li><a href="{$e_url}"><img src="{$web_public_path}/images/home/prolist_29.gif" /></a></li></ul>
EOT;
		 $this->assign("divpage",$div_str);
		  /*分页处理结束*/
		 
	     if(C("diy_cache"))$mycache->create_cache($this->fetch());//创建缓存 
	     $this->display();
	  }
	}
	public function job_info(){
	  import("ORG.Com.DiyCache");
	  $mycache = new DiyCache;
	  if(!$mycache->is_cached()){//处理自定义缓存
		 /*安全处理*/
		 checkget();
		 checkpost();
		 $id = $_GET['id'];
		 if(empty($id)||!is_numeric($id))alert('参数错误');
		 /*安全处理*/
		 $job = M("job");
		 $job_info = $job->where("id = $id")->find();
		 $this->assign("job_info",$job_info);
		 
		 //职位列表
		 Vendor("LJW.Page");
		 $count = $job->count();
		 $pagesize = 8;
		 $mypage = new Page($count,$pagesize,3,U("Job/index"));
		 
		 $job_list = $job->limit($mypage->start.",".$mypage->pagesize)->order("sequence desc")->findAll();
		 
		 
		 $this->assign("job_list",$job_list);
		 
		 /*分页处理开始*/
		 $f_url=$mypage->url."/p/1";//首页
		 $e_url=$mypage->url."/p/".$mypage->pagenum;//尾页
             
		 $p_url=$mypage->url."/p/".(($mypage->absolutepage-1<=0)?1:($mypage->absolutepage-1));//上一页
		 $n_url=$mypage->url."/p/".(($mypage->absolutepage+1>$mypage->pagenum)?$mypage->pagenum:($mypage->absolutepage+1));//下一页
		 
		 $web_public_path = WEB_PUBLIC_PATH;
		 
		 
		 $div_str = <<<EOT
		 <ul><li><a href="{$f_url}"><img src="{$web_public_path}/images/home/prolist_22.gif" /></a></li><li><a href="{$p_url}"><img src="{$web_public_path}/images/home/prolist_24.gif" /></a></li>
EOT;
        for($i=1;$i<=$mypage->pagenum;$i++){
			    $u=$mypage->url."/p/$i";
			    $div_str.="<li><a href='$u'>$i</a></li>";
		}
		$div_str.=<<<EOT
		<li><a href="{$n_url}"><img src="{$web_public_path}/images/home/prolist_27.gif" /></a></li><li><a href="{$e_url}"><img src="{$web_public_path}/images/home/prolist_29.gif" /></a></li></ul>
EOT;
		 $this->assign("divpage",$div_str);
		 /*分页处理结束*/
		 
	     if(C("diy_cache"))$mycache->create_cache($this->fetch());//创建缓存 
	     $this->display();
	  }
	}
}

?>